﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

using Happy.ExtentionMethods.Reflection;

namespace Happy.Test.Infrastructure.ExtentionMethods.Reflection
{
    [TestClass]
    public class CustomAttributeProviderExtensionsTest
    {
        [TestMethod]
        public void GetAttributes_With_No_Attibute_Test()
        {
            var attibutes =
                typeof(CustomAttributeProviderExtensionsTest)
                .GetAttributes<SerializableAttribute>();

            Assert.AreEqual(0, attibutes.Length);
        }

        [TestMethod]
        public void GetAttributes_With_Have_Attibute_Test()
        {
            var attibutes =
                typeof(CustomAttributeProviderExtensionsTest)
                .GetAttributes<TestClassAttribute>();

            Assert.AreEqual(1, attibutes.Length);
        }


        [TestMethod]
        public void GetAttribute_With_No_Attibute_Test()
        {
            var attibute =
                typeof(CustomAttributeProviderExtensionsTest)
                .GetAttribute<SerializableAttribute>();

            Assert.IsNull(attibute);
        }

        [TestMethod]
        public void GetAttribute_With_Have_Attibute_Test()
        {
            var attibute =
                typeof(CustomAttributeProviderExtensionsTest)
                .GetAttribute<TestClassAttribute>();

            Assert.IsNotNull(attibute);
        }
    }
}
